﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using WebUI.Areas.Bots.Models;
using DAL;
using Entities;

namespace WebUI.Areas.Bots.Controllers
{
    public partial class GeneralController : BaseController
    {
        #region Constructor

        public GeneralController(ISessionHelper sessionHelper)
            : base(sessionHelper)
        {
        }

        #endregion

        #region Action Methods

        public virtual ViewResult Index()
        {
            BOT bot = _sessionHelper.Bot;
            General model = new General { Name = bot.BotName, Description = bot.BotDescription };
            return View(model);
        }

        [HttpPost]
        public virtual ActionResult Save([Bind(Exclude = "Id")]General model)
        {
            if (ModelState.IsValid)
            {
                _sessionHelper.Bot.BotName = model.Name;
                _sessionHelper.Bot.BotDescription = model.Description;
                return RedirectToRoute(new { action = "Index", controller = MVC.Bots.BotType.Name, step = MVC.Bots.BotType.Name });
            }

            return View(MVC.Bots.General.ActionNames.Index, model);
        }

        #endregion
    }
}